<!DOCTYPE html>
<html lang="en" dir="ltr">

<head>
  <meta charset="UTF-8">
  <title>Radio - a11y</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <link href="../../../../../css/ionic.bundle.css" rel="stylesheet">
  <link href="../../../../../scripts/testing/styles.css" rel="stylesheet">
  <script src="../../../../../scripts/testing/scripts.js"></script>
  <script nomodule src="../../../../../dist/ionic/ionic.js"></script>
  <script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script></head>

<body>
  <ion-app>
    <ion-header>
      <ion-toolbar>
        <ion-title>Radio - a11y</ion-title>
      </ion-toolbar>
    </ion-header>

    <ion-content id="content" class="outer-content">
      <div class="native-radio-group">
        <p>Select a maintenance drone (native):</p>

        <div>
          <input type="radio" id="huey" name="drone" value="huey" checked>
          <label for="huey">Huey</label>
        </div>

        <div>
          <input type="radio" id="dewey" name="drone" value="dewey">
          <label for="dewey">Dewey</label>
        </div>

        <div>
          <input type="radio" id="fooey" value="fooey" disabled/>
          <label for="fooey">Fooey</label>
        </div>

        <div>
          <input type="radio" id="louie" name="drone" value="louie">
          <label for="louie">Louie</label>
        </div>
      </div>

      <ion-list>
        <ion-list-header>
          <ion-label>
            Select a maintenance drone:
          </ion-label>
        </ion-list-header>
        <ion-radio-group value="huey">
          <ion-item>
            <ion-label>Huey</ion-label>
            <ion-radio slot="start" value="huey"></ion-radio>
          </ion-item>

          <ion-item>
            <ion-label>Dewey</ion-label>
            <ion-radio slot="start" value="dewey"></ion-radio>
          </ion-item>

          <ion-item>
            <ion-label>Fooey</ion-label>
            <ion-radio slot="start" value="fooey" color="secondary" disabled></ion-radio>
          </ion-item>

          <ion-item>
            <ion-label>Louie</ion-label>
            <ion-radio slot="start" value="louie"></ion-radio>
          </ion-item>
        </ion-radio-group>
      </ion-list>

      <ion-list>
        <ion-radio-group value="huey">
          <ion-item>
            <ion-label>Huey</ion-label>
            <ion-radio slot="start" value="huey" color="danger"></ion-radio>
          </ion-item>

          <ion-item>
            <ion-label>Dewey</ion-label>
            <ion-radio slot="start" value="dewey" color="secondary"></ion-radio>
          </ion-item>

          <ion-item>
            <ion-label>Fooey</ion-label>
            <ion-radio slot="start" value="fooey" color="secondary" disabled></ion-radio>
          </ion-item>

          <ion-item>
            <ion-label>Louie</ion-label>
            <ion-radio slot="start" value="louie" color="tertiary"></ion-radio>
          </ion-item>
        </ion-radio-group>
      </ion-list>

      <div style="padding: 10px 16px">
        <ion-radio-group value="louie">
          <h5>Custom Labels</h5>
          <div>
            <ion-radio id="custom-huey" value="huey"></ion-radio>
            <label for="custom-huey">Huey</label>
          </div>
          <div>
            <ion-radio id="custom-dewey" value="dewey"></ion-radio>
            <label for="custom-dewey">Dewey</label>
          </div>
          <div>
            <ion-radio id="custom-fooey" value="fooey" disabled></ion-radio>
            <label for="custom-fooey">Fooey</label>
          </div>
          <div>
            <ion-radio id="custom-louie" value="louie"></ion-radio>
            <label for="custom-louie">Louie</label>
          </div>
        </ion-radio-group>
      </div>
    </ion-content>

  </ion-app>
</body>

<style>
  ion-list {
    margin-bottom: 10px !important;
  }

  .native-radio-group {
    background: white;
    padding: 10px 16px;
    margin-bottom: 10px;
  }

  .native-radio-group div {
    margin: 10px 0;
  }
</style>

<script>
  const inputs = document.querySelectorAll('ion-radio');

  for (var i = 0; i < inputs.length; i++) {
    const input = inputs[i];

    input.addEventListener('ionBlur', function() {
      console.log('Listen ionBlur: fired');
    });

    input.addEventListener('ionFocus', function() {
      console.log('Listen ionFocus: fired');
    });

    input.addEventListener('ionChange', function(ev) {
      console.log('Listen ionChange: fired', ev.detail);
    });

    input.addEventListener('click', function() {
      console.log('Listen click: fired');
    });
  }
</script>

</html>
